State vs. Props
A very common beginner question or sometimes even an interview question is this, what’s the difference between state and props?
Well, we actually already learned almost everything to answer that question, but let’s still make the difference between state and props crystal clear in this lecture, which will also serve as a nice summary to this entire section.
So as we already know, state is internal data. So data that is owned by the component in which it is declared, and we can see that nicely in this small example with two components. Now, on the other hand, props is external data.
So data that is owned by the parent component, and you can think of props as function parameters. So as a communication channel between parent and child components where parents can pass data into children.
State on the other hand can be thought of as the component’s memory because it can hold data over time, so across multiple re-renders.
Now state can be updated by the component itself and as we already know, this will then cause the component to be re-rendered by React. Therefore, we use this mechanism of state to make components interactive.